<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="${ctx}/css/common.css" />
<link rel="stylesheet" href="${ctx }/css/">
<jsp:include page="../inc.jsp"></jsp:include>
<meta http-equiv="X-UA-Compatible" content="edge" />
<title>合同订单-查看详情</title>
<style>
		input{
			width:120px;
			height:18px;
			border:1px solid #77b2e0;
			border-radius: 3px;
		}
		 .mynewBtn{
		display: block;
		width:60px;
		height:20px;
		background: #3989c8;
		margin-left:18px;
		margin-top:3px;
		float: left;
		color: #FFFFFF;
		border:1px solid #3989c8;
		-moz-border-radius: 3px;      /* Gecko browsers */
	    -webkit-border-radius: 3px;   /* Webkit browsers */
	    border-radius:3px;
	    cursor:pointer;
	}
		select{
			height:20px;
			border:1px solid #77b2e0;
			border-radius: 3px;
		}
		.searchBox{
			width:1100px; 
			height:40px;
		}
		.searchBox li{
			float:left;
			margin-top:5px;
			margin-left:15px;
		}
		.tableOntab td{
			height:37px;
			border-right:none;
		}
		.tableOntab .borderNone{
			border-bottom:none;
		}
		.query{
			margin-left:5px;
		}
		/*使按钮居中*/
		.autoBoxTwo{
			width:180px;
			height:26px;
			margin:15px auto; 
		}
		input::-ms-clear{display:none;}
		.pew{
   			color:#ff0101;
   			font-size:14px;
   		}
</style>

<script type="text/javascript">
	$(function(){
		var conStatus= ${param.conStatus};
		conStatus=CommonConverter.toContractStatusStr(conStatus);
		$("#conStatus").text(conStatus);//填充合同状态
		//加载表格信息
		dataGrid = $('#ticketTable').datagrid({
			url:'${ctx}/search/contractDetailForPlatform?conNo=${param.conNo}&temp='+Math.random(),
			striped : true,
			singleSelect : true,
			idField : 'id',
			pageList : [5,10,20],
			//sortName : 'id',
			//sortOrder : 'asc',
			method : 'get',
			toolbar:'#toolbar',
			pagination:true,
			
			columns:[[
			          {
							width : '80',
							title : 'id',
							field : 'id',
							hidden : true,
						},{
							width : '180',
							title : '订单号',
							align:'center',
							field : 'orderNumber',
						},{
				width : '80',
				title : '航班号',
				align : 'center',
				field : 'airlineId',
				formatter : function(value,row){
					var table;
					if(row.list != null && row.list.length > 0){
						if(row.list.length == 1){
							table='<table class="tableOntab" style="width:80px;"><tr><td>'+((row.list))[0].airlineNumber+'</td></tr></table>';
						}else if(row.list.length == 2){
							table='<table class="tableOntab" style="width:80px;"><tr><td>'+((row.list))[0].airlineNumber+'</td>'+'</tr><tr>'+'<td class="borderNone">'+((row.list))[1].airlineNumber+'</td></tr></table>';
						}
					}
					return table;
				}
			},{
				width : '150',
				title : '出发',
				align : 'center',
				field : 'charterTypeStr',
				formatter : function(value,row){
					var table;
					if(row.list != null && row.list.length > 0){
						if(row.list.length == 1){
							table='<table class="tableOntab" style="width:150px;"><tr><td>'+(row.list)[0].deptCity+'('+(row.list)[0].deptCode+')</td></tr></table>';
						}else if(row.list.length == 2){
							table='<table class="tableOntab" style="width:150px;"><tr><td>'+(row.list)[0].deptCity+'('+(row.list)[0].deptCode+')'+'</td>'+'</tr><tr>'+'<td class="borderNone">'+(row.list)[1].deptCity+'('+(row.list)[1].deptCode+')'+'</td></tr></table>';
						}
					}
					return table;
				}
			},{
				width : '150',
				title : '到达',
				align : 'center',
				field : 'scheduleId',
				formatter : function(value,row){
					var table;
					if(row.list != null && row.list.length > 0){
						if(row.list.length == 1){
							table='<table class="tableOntab" style="width:150px;"><tr><td>'+(row.list)[0].arrCity+'('+(row.list)[0].arrCode+')</td></tr></table>';
						}else if(row.list.length == 2){
							table='<table class="tableOntab" style="width:150px;"><tr><td>'+(row.list)[0].arrCity+'('+(row.list)[0].arrCode+')'+'</td>'+'</tr><tr>'+'<td class="borderNone">'+(row.list)[1].arrCity+'('+(row.list)[1].arrCode+')'+'</td></tr></table>';
						}
					}
					return table;
				}
			},{
				width : '100',
				title : '出发日期',
				align : 'center',
				field : 'scheduleIdStr',
				formatter : function(value,row){
					var table;
					if(row.list != null && row.list.length > 0){
						if(row.list.length == 1){
							table='<table class="tableOntab" style="width:100px;"><tr><td>'+(row.list)[0].deptDate+'</td></tr></table>';
						}else if(row.list.length == 2){
							table='<table class="tableOntab" style="width:100px;"><tr><td>'+(row.list)[0].deptDate+'</td>'+'</tr><tr>'+'<td class="borderNone">'+(row.list)[1].deptDate+'</td></tr></table>';
						}
					}
					return table;
				}
			},{
				width : '100',
				title : '出发时刻',
				align:'center',
				field : 'journeyType',
				formatter : function(value,row){
					var table;
					if(row.list != null && row.list.length > 0){
						if(row.list.length == 1){
							table='<table class="tableOntab" style="width:100px;"><tr><td>'+CommonConverter.formatFlightTime((row.list)[0].deptTime)+'</td></tr></table>';
						}else if(row.list.length == 2){
							table='<table class="tableOntab" style="width:100px;"><tr><td>'+CommonConverter.formatFlightTime((row.list)[0].deptTime)+'</td>'+'</tr><tr>'+'<td class="borderNone">'+CommonConverter.formatFlightTime((row.list)[1].deptTime)+'</td></tr></table>';
						}
					}
					return table;
				}
			},{
				width : '60',
				title : '状态',
				align:'center',
				field : 'orderStatus',
				formatter:function(value,row){
					return CommonConverter.toOrderBizStatusStr(row.orderStatus);
				}
			},{
				width : '80',
				title : '出票率(%)',
				align:'center',
				field : 'tick',
				formatter : function(value,row){
					var str="";
					if(row.ticketRate!=row.oldTicketRate){
						str='<span class="pew">'+row.ticketRate+'</span>'+'<br/>'+'<s>'+row.oldTicketRate+'</s>';
					}else{
						str='<span class="pew">'+row.ticketRate+'</span>';
					}
					return str;
					//var str='<span class="pew">'+row.deposit+'</span>'+'<br/>'+'<s>'+row.oldDeposit+'</s>';
					//return str;
				}
				
			},{
				width : '80',
				title : '票损(CNY)',
				align:'center',
				field : 'Loss',
				formatter : function(value,row){
					var str="";
					if(row.ticketLoss!=row.oldTicketLoss){
						str='<span class="pew">'+row.ticketLoss+'</span>'+'<br/>'+'<s>'+row.oldTicketLoss+'</s>';
					}else{
						str='<span class="pew">'+row.ticketLoss+'</span>';
					}
					return str;
					//var str='<span class="pew">'+row.deposit+'</span>'+'<br/>'+'<s>'+row.oldDeposit+'</s>';
					//return str;
				}
				
			},{
				width : '140',
				title : '单价(CNY)',
				align:'center',
				field : 'oldSellingPrice',
				formatter:function(value,row){
					//return row.oldSellingPrice+"/"+row.sellingPrice;
					var str="";
					if(row.oldSellingPrice!=row.sellingPrice){
						str='<span class="pew">'+row.sellingPrice+'</span>'+'<br/>'+'<s>'+row.oldSellingPrice+'</s>';
					}else{
						str='<span class="pew">'+row.sellingPrice+'</span>'
					}
					return str;
					//var str='<span class="pew">'+row.deposit+'</span>'+'<br/>'+'<s>'+row.oldDeposit+'</s>';
					//return str;
				}
			},{
				width : '140',
				title : '预定数量/出票数量(CNY)',
				align:'center',
				field : 'ac',
				formatter:function(value,row){
					if(row.orderStatus==0){ //待支付状态时,实际出票数量强制显示为0，其它状态则正常显示为出票的数量
						return CommonConverter.toEmptyString(row.purchQuantity)+"/"+"0";
					}else{
						return CommonConverter.toEmptyString(row.purchQuantity)+"/"+CommonConverter.toEmptyString(row.actualTicketedCount);
					}
				}
			},{
				width : '100',
				title : '应付总价(CNY)',
				align:'center',
				field : 'sum'
	
			},{
				width : '110',
				title : '操作',
				align:'center',
				field : 'fareSaleStr',
				formatter:function(value,row){
					var str = '<span class="mynewBtn" onclick=Log("'+row.orderNumber+'")>查看日志</span>';
					if(row.orderStatus == 4){
						str += '<span class="mynewBtn" onclick=Look("'+row.orderNumber+'")>查看名单</span>';
					}
					return str;
				}
			}
			] ]
		});
		
		
	});
	//查看名单弹出框
	function Look(orderNumber) {
		//alert(orderNumber);
		layer.open({
			type: 2,
			title: ['订单管理-查看票号','background-color:#00B2EE; color:#fff;'],
			shadeClose: true,
			shade: 0.3,
			area: ['1020px', '500px'],  
			content: ['${ctx}/order/orderTickets/'+orderNumber, 'no'], //iframe的url，no代表不显示滚动条
		});
	};
    
	//查看日志
	function Log(orderNumber){
		//alert(orderNumber);
		layer.open({
			type: 2,
			title: ['订单操作记录','background-color:#00B2EE; color:#fff;'],
			shadeClose: true,
			shade: 0.5,
			area: ['750px', '450px'],
			content: ['${ctx}/nporder/logs/'+orderNumber, 'no'],
			success: function(layero, index){
			},
			end:function(){
			}
		});
	};
</script>
</head>
<body style="padding-left:10px;padding-top:10px;">
	<div class="easyui-layout" data-options="fit:true,border:false" >
		 <div data-options="region:'north',border:false">
			<ul class="searchBox">
					<li>
						合同号：<span id="cashNo">${param.conNo}</span>
					</li>
					<li>
						合同状态：<span id="conStatus"></span>
					</li>
					<li>
						支付截止时间：<span id="payOverTime">${payOverTime}</span>
					</li>
					
				</ul>
			</div>
			 <div data-options="region:'center',border:false">
				<table id="ticketTable" data-options="fit:true"></table>
			</div>
		</div>
</body>
</html>